{% extends "../component/_latout.html" %}
{% block style %}
<link href="/public/admin/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="/public/admin/css/plugins/webuploader/webuploader.css">
<link rel="stylesheet" type="text/css" href="/public/admin/css/demo/webuploader-demo.min.css">
{% endblock %}
{% block content %}
<!--wrap-->
<div class="" >
    <!--页面参数-->
    
    <input value="{% if folder %}{{folder.id}}{% else %}0{% endif %}" type="hidden" id="folderId" />
    <input value="{% if folder %}{{folder.parent_id}}{% else %}0{% endif %}" type="hidden" id="parentFolderId" />
   
    <!--页面参数-->
    <!--主体部分-->
    <div class="row">
        <div class="col-sm-12">
          <div class="ibox float-e-margins  m-b-none">
              <div class="ibox-title">
                  <h5>资源-资源列表 
                    <span class="m-l-xl">
                    当前位置：
                    <a {% if folder %}href="/admin/resource/list"{% endif %}>根目录</a>
                    {% if folder.grandParent %}
                    / <a  {% if folder.parent %}href="/admin/resource/list?folderId={{folder.grandParent.id}}"{% endif %}>{{folder.grandParent.name}}</a>
                    {% endif %}
                    {% if folder.parent %}
                    / <a {% if folder %}href="/admin/resource/list?folderId={{folder.parent.id}}"{% endif %}>{{folder.parent.name}}</a>
                    {% endif %}
                    {% if folder %}
                    / <a>{{folder.name}}</a>
                    {% endif %}
                    </span>
                  </h5>
                  <div class="ibox-tools">
                      {# <a class="collapse-link">
                          <i class="fa fa-chevron-up"></i>
                      </a>
                      <a class="close-link">
                          <i class="fa fa-times"></i>
                      </a> #}
                  </div>
              </div>
              <div class="ibox-content">
                <div class="clear">
                    {% if folder %}
                    <div class="pull-left m-r-xl">
                        <a class="btn btn-primary" type="button" href="/admin/resource/list">返回根目录</a>
                        <a class="btn btn-primary m-l-sm" type="button" href="/admin/resource/list{% if folder.parent_id  %}?folderId={{folder.parent_id}}{% endif %}">返回上级目录</a>
                    </div>
                    {% endif %}
                    <div class="m-r-xl  btn-group pull-left" id="typeSwitch">
                        <a class="btn btn-outline btn-primary {% if ctx.query.type %}{% else %}active{% endif %}">全部</a>
                        <a class="btn btn-outline btn-primary {% if ctx.query.type == 1 %}active{% endif %}" type="1">图片</a>
                        <a class="btn btn-outline btn-primary {% if ctx.query.type == 2 %}active{% endif %}" type="2">文档</a>
                        <a class="btn btn-outline btn-primary {% if ctx.query.type == 3 %}active{% endif %}" type="3">视频</a>
                    </div>
                    <div class="pull-left m-r-xl">
                        {% if folder.grandParent == null %}
                        <button class="btn btn-primary" type="button" id="newFolder">新建文件夹</button>
                        {% endif %}
                        {# <button class="btn btn-primary m-l-sm" type="button" >批量删除</button> #}
                        <a class="btn btn-primary m-l-sm" type="button" href="/admin/upload{% if folder %}?folderId={{folder.id}}{% endif %}">上传文件</a>
                    </div>
                    
                    <div class="pull-left m-r-xl search-container">
                        <div class="input-group">
                            <input type="text" name="keyword" value="{{ctx.query.name}}" id="keyword" placeholder="请输入文件、文件夹名" class="input-sm form-control ">
                            <span class="input-group-btn m-b-none"><button type="button" id="submitSearch" class="btn btn-sm btn-primary">确定</button> </span>
                        </div>
                    </div>
                </div>
              </div>
          </div>
        </div>
    </div>
    <!--/主体部分-->

     <!--主体部分-->
    <div class="row">
        <div class="col-sm-12">
          <div class="ibox float-e-margins  m-b-none">
                <div class="ibox-content">
                    <table class="table table-hover  m-b-none" >
                        <thead>
                            <tr>
                                {# <th class="bs-checkbox">
                                    <div class="th-inner ">
                                        <input name="btSelectAll" type="checkbox">
                                    </div>
                                    <div class="fht-cell"></div>
                                </th> #}
                                <th>
                                    <div class="th-inner ">文件名</div>
                                    <div class="fht-cell"></div>
                                </th>
                                <th>
                                    <div class="th-inner ">缩略图</div>
                                    <div class="fht-cell"></div>
                                </th>
                                <th>
                                    <div class="th-inner ">文件大小</div>
                                    <div class="fht-cell"></div>
                                </th>
                                <th>
                                    <div class="th-inner ">最后修改时间</div>
                                    <div class="fht-cell"></div>
                                </th>
                                <th>
                                    <div class="th-inner ">操作</div>
                                    <div class="fht-cell"></div>
                                </th>
                            </tr>
                        </thead>
                        <tbody>
                            {% if children.length != 0 or files.length !=0 %}
                            {% for fold in children %}
                            <tr>
                                {# <td class="bs-checkbox">
                                    <input name="btSelectItem" type="checkbox">
                                </td> #}
                                <td class="text-success">
                                    <a href="/admin/resource/list?folderId={{ fold.id }}"><i class="fa fa-folder" aria-hidden="true"></i> {{fold.name}}</a>
                                </td>
                                <td class="text-success">
                                    --
                                </td>
                                <td class="text-success">--</td>
                                <td> {{fold.modify_time}}</td>
                                <td>   
                                    <a href="/admin/resource/list?folderId={{ fold.id }}">进入文件夹</a>
                                    <a href="javascript:void(0)" class="edit_folder" folderId="{{ fold.id }}" folderName="{{fold.name}}">改名</a>
                                    <a href="javascript:void(0)" class="delete_folder" folderId="{{ fold.id }}">删除</a>
                                    <div>
                                </td>
                            </tr>
                            {% endfor %}
                            {% for file in files %}
                            <tr>
                                {# <td class="bs-checkbox">
                                    <input name="btSelectItem" type="checkbox">
                                </td> #}
                                <td class="text-success name-ellipse">
                                    {% if file.type == 1 %}
                                    <i class="fa fa-picture-o" aria-hidden="true"></i>
                                    {% elseif file.type == 2 %}
                                    <i class="fa fa-file-pdf-o" aria-hidden="true"></i>
                                    {% elseif file.type == 3 %}
                                    <i class="fa fa-video-camera" aria-hidden="true"></i>
                                    {% endif %}<a tabname="资源详情 | 测试.png" class="J_menuItem" href="/admin/resource/detail?fileId={{file.id}}">{{file.name}}</a>
                                </td>
                                <td>
                                    {% if file.type == 1 %}
                                    <img src="{{file.url}}" width="40" height="40">
                                    {% elseif file.type == 2 %}
                                    文档资源
                                    {% elseif file.type == 3 %}
                                    视频资源
                                    {% endif %}
                                </td>
                                <td>{{file.size}}</td>
                                <td> {{file.modify_time}}</td>
                                <td>   
                                    <a tabname="资源详情 | {{file.name}}" class="J_menuItem" href="/admin/resource/detail?fileId={{file.id}}">详情</a>
                                    <a href="{{file.url}}" target="_blank">{% if file.type == 1 or file.type ==3 or file.mime == "application/pdf" %}预览{% else %}下载{% endif %}</a>
                                    <input type="text" class="copy_target_input" id="copy_target_{{ file.id }}"  value="{{file.url}}"/>
                                    <a href="javascript:void(0)" class="clipUrl" fileId="{{ file.id }}" data-clipboard-action="copy" data-clipboard-target="#copy_target_{{ file.id }}" id="clip_borad_{{ file.id }}" >复制链接</a>
                                    <a href="javascript:void(0)" class="edit_file" fileId="{{ file.id }}" fileName="{{file.name}}">改名</a>
                                    <a href="javascript:void(0)" class="delete_file" fileId="{{ file.id }}">删除</a>
                                    <div>
                                </td>
                            </tr>
                            {% endfor %}
                            {% else %}
                            <tr>
                                <td colspan="5">
                                <!--没有数据时的显示-->
                                <div class="no-data-container">
                                <i class="fa fa-frown-o"></i>
                                <span>该文件夹暂无任何文件</span>
                                </div>
                                <!--/没有数据时的显示-->
                                </td>
                            </tr>
                            {% endif %}
                        </tbody>
                    </table>
                </div>
          </div>
        </div>
    </div>
    <!--/主体部分-->
</div>

{% endblock %} 
{% block script %}
<script src="/public/admin/js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="/public/admin/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="/public/admin/js/hplus.min.js"></script>
<script src="/public/admin/js/plugins/clipborad/clipborad.js"></script>
<script src="/public/admin/js/common/resource/list.js"></script>
{% endblock %} 
